package edu.scu.declaresys.service.impl;

import org.apache.commons.codec.digest.DigestUtils;

import edu.scu.declaresys.dao.DAOFactory;
import edu.scu.declaresys.dao.intr.ILoginLogDAO;
import edu.scu.declaresys.exception.ExecuteException;
import edu.scu.declaresys.service.intr.IUserValidateService;
import edu.scu.declaresys.vo.User;

/**
 * 
 * @author: zt
 * @since : 2013-7-5
 */
public class UserValidateServiceImpl implements IUserValidateService
{
	@SuppressWarnings("unused")
	private ILoginLogDAO loginDao = DAOFactory.createLoginLogDAO();
	
	@Override
	public User login(String loginName, String pswd) throws ExecuteException
	{
		String pswdMd5 = DigestUtils.md5Hex(pswd);
		//
		User user = DAOFactory.createUserDAO().findByNameAndPswd(loginName, pswdMd5);
		//
		// Check login name and password.
		if(user == null)
		{
			return null;
		}
		//TODO:写日志
		//登录成功
		return user;
	}
	
	
	
	@Override
	public String logout() throws ExecuteException
	{
		// TODO 记录日志
		return null;
	}
	
}
